<!DOCTYPE HTML>
<html  xmlns:th="http://www.thymeleaf.org">
<head th:include="_meta :: header">
<title>添加</title>
</head>
<body>
<div class="layui-fluid">
    <div class="layui-row">
        <form class="layui-form form form-horizontal"  id="form-test-add" action="#" th:action="@{/test/test/add}" method="post">
            <div class="layui-form-item">
                <label class="layui-form-label"><span class="x-red">*</span>姓名：</label>
                <div class="layui-input-inline">
                        <input type="layui-input" class="layui-input" th:name="testName"
                               placeholder="填写" id="testName"/>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label"><span class="x-red">*</span>性别：</label>
                <div class="layui-input-inline">

                    <select name="testSex" id="testSex" class="layui-input" type="layui-input" >
                        <option value="">搜索状态</option>
                        <option value="0">男</option>
                        <option value="1">女</option>
                    </select>
                </div>
            </div>
            
            <div class="layui-form-item">
                <label class="layui-form-label">
                </label>
                <button  class="layui-btn" id="subbtn" type="submit" >
                    增加
                </button>
                <button  class="layui-btn" id="reset" type="reset" >
                    重置
                </button>
            </div>
        </form>
    </div>
</div>

<!--_footer 作为公共模版分离出去-->
<div th:replace="_footer :: footerjs"></div>
<div th:replace="_ueditor :: ueditor"></div>
 <!--/_footer 作为公共模版分离出去-->
<!--请在下方写此页面业务相关的脚本-->
<script>
    layui.use(['form', 'layer','laydate'],function() {
        $ = layui.jquery;
        var form = layui.form,
            laydate = layui.laydate,
            layer = layui.layer;
        lay('.timeSpace').each(function(){
            laydate.render({
                elem: this
                ,trigger: 'click'
                ,type: 'datetime'
            });
        });
    });
 $(function(){
	$("#form-test-add").validate({
		rules:{
            testName:{
                required: true,
			},
            testSex:{
                required: true,
			},
		},
		onkeyup:false,
		debug: true,
		success:"valid",
		submitHandler:function(form){
				$(form).ajaxSubmit({
				type: 'POST',
				url: "/test/test/add" ,
				success: function(data){
					if(data.code == "1"){
						selfmsg('添加成功!',1,function(){
							var index = parent.layer.getFrameIndex(window.name);
							parent.location.reload();
							parent.layer.close(index);
						});
					}else{
						selfmsg('添加失败!');
					}
				},
                error: function(){
					selfmsg('添加异常!',5);
				}
			});
		}
	});
});

</script>
<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>